<?php

	require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php");
	gatekeeper();

	$maxfriends = get_entities_from_relationship("friend", get_loggedin_userid(), null, null, null, null, null, null, null, true);
	$friends = get_entities_from_relationship("friend", get_loggedin_userid(), null, null, null, null, null, $maxfriends);
	
?>
	
	
	<?php
		$online = "";
		$numOnline = 0;
		$offline = "";
		$numOffline = 0;
		
		foreach($friends as $friend){
			$friend_text = "";
			$friend_text .= "<img class='messageIcon' alt='" . $friend->name . "' src='". $friend->getIcon('tiny') . "'>";
			$friend_text .= "<a href='javascript:startSession(" . $friend->guid . "); toggleFriendsPicker();'>" . $friend->name . "</a><br />";
			if(time() - $friend->last_action < 600){
				$online .= $friend_text;
				$numOnline++;
			} else {
				$offline .= $friend_text;
				$numOffline++;
			}
		}
		
		echo "<h3 class='settings'>Friends Online (" . $numOnline . ")</h3>" . $online . "<h3 class='settings'>Friends Offline (" . $numOffline . ")</h3>". $offline;
	?>
	